/*
 
Copyright Eric C. McCreath 2012  <ericm@cs.anu.edu.au>

This file is part of the clapper-webcam-recorder project.

clapper-webcam-recorder is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.

clapper-webcam-recorder is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with clapper-webcam-recorder.  If not, see <http://www.gnu.org/licenses/>.

 */



#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/time.h>


void errno_exit(const char * s)
{
        fprintf (stderr, "%s error %d, %s\n",
                 s, errno, strerror (errno));
        exit (EXIT_FAILURE);
}

void errno2_exit(char str1[], char str2[])
{
        fprintf (stderr, str1, str2);
        fprintf (stderr, "errno : %d, %s\n",
                  errno, strerror (errno));
        exit (EXIT_FAILURE);
}

void s1_exit(char str1[])
{
        fprintf (stderr, "%s", str1);
        exit (EXIT_FAILURE);
}

void s2_exit(char str1[], char str2[])
{
        fprintf (stderr, str1, str2);
        exit (EXIT_FAILURE);
}

void s3_exit(char str1[], char str2[], char str3[])
{
        fprintf (stderr, str1, str2, str3);
        exit (EXIT_FAILURE);
}



double secondsfrom() {
    struct timeval tv;
    struct timezone tz;

    gettimeofday(&tv, &tz);
    return tv.tv_usec / 1000000.0 + tv.tv_sec;
}
